{include file="public/head" /}
<body>
{include file="public/menu" /}
<div class="recharge">
    <div class="wrap">
        <div class="subnav commonTab">
            <div>
                <span class="ac">快捷充值</span>
                <span>网银充值</span>
            </div>
            <!--<span>转账充值(暂未开通)</span>-->
        </div>
        <ul id="content">
            <p style="box-sizing: border-box;margin: 0;color: rgba(0, 0, 0, 0.65);font-size: 14px;
    font-variant: tabular-nums;
    line-height: 1.5;
    list-style: none;
    font-feature-settings: 'tnum';
    position: relative;
    padding: 8px 15px 8px 37px;background-color: #fffbe6;margin-top: 16px;text-align: center;">尊敬的用户，信用卡功能因政策原因已停用</p>
            <li class="showli">
                <form action="" onSubmit="return false">
                    <h3>
                        <span class="label">账户余额：</span><span class="color">{$member.money}元</span>
                    </h3>
                    <div class="money">
                        <label>充值金额(元)：</label>
                        <input autocomplete="off" type="number" min="0" id="money" class="recharge-amount amount1" onkeyup="getFee(this)">
						<p style="font-size: 10px;color: #fd7400;margin-top: 11px;display:none;" class="feenote"><span class="label"></span>手续费：￥<em class="fee">0</em></p>
                    </div>
					<div class="money">
						<label>银行卡：</label>
						<select name="bank" id="bank" style="width: 320px; height: 40px; border: 1px solid #dbdbdb;">
							<option value="">-选择银行卡-</option>
							{volist name="CardList" id="vo"}
							<option value="{$vo.id}">{:PutPrivateNumber($vo.bank_number)}[{$vo.bank_name}]</option>
							{/volist}
						</select>
					</div>
                    <div class="money">
                        <label>支付金额(元)：</label>
                        <input type="text" id="payMoney" class="recharge-amount amount1" readonly>
                    </div>
                    <div class="money">
                        <label>支付密码：</label>
                        <input autocomplete="off" type="password" id="paypass" class="amount1">
                    </div>
                    <div class="money" id="smsVerifcode" style="display: none">
                        <label style="color:red">短信验证码：</label>
                        <input autocomplete="off" type="text" id="paycode" class="recharge-amount amount1">
                    </div>
                    <div class="next next1" id="surPay">
                        <span class="label"></span>
                        <input type="submit" id="QUICKPC" value="提    交">
                    </div>
					<p style="font-size: 12px;color: #cccccc;margin-top: 11px;text-align: center;"><span class="label"></span>注：最低充值金额{:confv('min-rechage')}元</p>
                </form>
            </li>
            <li>
                <form action="" onSubmit="return false;" >
                    <h3>
                        <span class="label">账户余额：</span><span class="color">{$member.money}元</span>
                    </h3>
                    <div class="money">
                        <label>充值金额(元)：</label>
                        <input type="number"  min="0" id="wymoney" class="recharge-amount amoun2" onkeyup="getFee2(this)">
						<p style="font-size: 10px;color: #fd7400;margin-top: 11px;display:none;" class="feenote2"><span class="label"></span>手续费：￥<em class="fee2">0</em></p>
                    </div>
					<div class="money">
						<label>充值银行：</label>
						<select name="bankcode" id="bankcode" style="width: 320px; height: 40px; border: 1px solid #dbdbdb;">
							<option value="">-选择网银-</option>
							{volist name="bankList" id="vo"}
							<option value="{$vo.bankCode}">{$vo.bankName}</option>
							{/volist}
						</select>
					</div>
                    <div class="money">
                        <label>支付金额(元)：</label>
                        <input type="text" id="payMoney2" class="recharge-amount amount1" readonly>
                    </div>
                    <div class="next next2">
                        <span class="label"></span>
                        <input type="submit" id="getBankInfo" value="下一步">
                    </div>
					<p style="font-size: 16px;color: #cccccc;margin-top: 11px;text-align: center;"><span class="label"></span>注：最低充值金额{:confv('min-rechage')}元</p>
                </form>
            </li>
        </ul>
    </div>
</div>
{include file="public/foot" /}
</body>
{include file="public/load_bottom" /}
<script>
    $(function(){
        var subnav = $('.subnav').find('span')
        var li = $('#content').find('li')
        subnav.click(function(){
            $(this).addClass('ac').siblings().removeClass('ac')
            li.eq($(this).index()).addClass('showli').siblings().removeClass('showli')
        })
    })
	
	function getFee(obj){
		var money = $(obj).val();
		if(money > 0){
			// $.get("{:url('Yun/getfee')}",{money:money},function(msg){
			// 	$(".feenote").show();
			// 	$(".fee").text(msg.info);
			// 	$("#payMoney").val(msg.url);
			// },'JSON')
            var fee=0;
            if(money>200){
                fee=money*0.005;
                fee=fee.toFixed(2);
            }else {
                fee=1;
            }
            $(".feenote").show();
            $(".fee").text(fee);
            $("#payMoney").val(parseFloat(money)+parseFloat(fee));
		}else{
			$(".feenote").hide();
            $("#payMoney").val('');
		}
	}
	function getFee2(obj){
		var money = $(obj).val();
		if(money > 0){
			$.get("{:url('Yun/getfee')}",{money:money},function(msg){
				$(".feenote2").show();
				$(".fee2").text(msg.info);
				$("#payMoney2").val(msg.url);
			},'JSON')
		}else{
			$(".feenote2").hide();
		}
	}	

	$('#QUICKPC').click(function(){
		 var reg = /^[0-9]+.?[0-9]*$/;
		 var val = $('#money').val();
		 var bank = $('#bank').val();
		 var paypass = $('#paypass').val();
		 if(!reg.test(val) || val==0 || val==''){
			layer.msg('请输入正确的金额');
			return false;
		 }
		 if(bank == ''){
			layer.msg('请选择支付银行卡');
			return false;
		 }
		 if(paypass.length != 6){
			layer.msg('请输入6位纯数字的支付密码');
			return false;
		 }
		 var index = layer.load(0, {shade: false});
        $('#QUICKPC').attr('disabled', true)
		 $.ajax({
			url: "{:url('Yun/createRorder')}",
			type:"POST",
			dataType:"JSON",
			data:{money:val,bank:bank,pwd:paypass},
			success:function(msg){
				layer.close(index);
				layer.msg(msg.info)
                $('#QUICKPC').attr('disabled', false)
				if(msg.status == 1){
				    $('#smsVerifcode').show()
                    $('#bank').attr('disabled', true)
                    $('#paypass').attr('disabled', true)
                    $('#payMoney').attr('disabled', true)
                    $('#money').attr('disabled', true)
					var str = '<span class="label"></span><input type="hidden" id="bizOrderNo" value="'+msg.url+'"><input type="submit" id="QUICKVSP" value="确认支付">';
					$("#surPay").html(str);
				}
			},
             error:function(xhr,status,errorThrown){
                 layer.close(index);
                 layer.msg(errorThrown)
             }
		 })
	})

	$("#getBankInfo").click(function(){
		var reg = /^[0-9]+.?[0-9]*$/;
		var val = $('#wymoney').val();
		var bankcode = $("#bankcode").val();
		 if(!reg.test(val) || val==0 || val==''){
			layer.msg('请输入正确的金额');
			return false;
		 }
		 if(bankcode == ''){
			layer.msg('请选择支付网银');
			return false;
		 }
		var index = layer.load(0, {shade: false});
		 $.ajax({
			url: "{:url('Yun/getWayPay')}",
			type:"POST",
			dataType:"JSON",
			data:{money:val,bankCode:bankcode},
			success:function(msg){
				layer.close(index);
				layer.msg(msg.info)
				if(msg.status == 1){
					window.location.href = msg.url;
				}
			},
             error:function(xhr,status,errorThrown){
                 layer.close(index);
                 layer.msg(errorThrown)
             },
		 })
	})
	
	$("body").on("click", "#QUICKVSP",function(){
		var bizOrderNo = $("#bizOrderNo").val();
		var paycode = $("#paycode").val();
		if(paycode.length !=6){
			layer.msg('请输入正确的验证码');
			return false;
		}
		if(bizOrderNo == ''){
			layer.msg('系统繁忙');
			return false;
		}
		 var index = layer.load(0, {shade: false});
		 $.ajax({
			url: "{:url('Yun/surepay')}",
			type:"POST",
			dataType:"JSON",
			data:{order:bizOrderNo,code:paycode},
			success:function(msg){
				layer.close(index);
				layer.msg(msg.info)
				if(msg.status == 1){
					setTimeout(function(){
						window.location.href = msg.url;
					},3000)
				}
			}
		 })
	});
</script>
</html>